package com.yazif.vqa.task;

import com.yazif.vqa.api.wechat.domain.Message;
import com.yazif.vqa.task.chain.DefualtTarget;

public abstract class AbstractTarget implements Target {

    public AbstractTarget target;

    public static final DefualtTarget DEFUALT_TARGET = new DefualtTarget();

    public abstract Message execute(Message message, Target target);

    public void setNextTarget(AbstractTarget target) {
        this.target = target;
    }

    @Override
    public final Message execute(Message message) {
        if (target == null) {
            target = DEFUALT_TARGET;
        }
        return execute(message, target);
    }
}
